package com.dfec.water.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dfec.common.exception.ServiceException;
import com.dfec.component.uid.core.service.UidService;
import com.dfec.framework.mybatis.core.page.PageParam;
import com.dfec.framework.mybatis.core.page.PageUtils;
import com.dfec.water.dao.YdbForecastDao;
import com.dfec.water.dao.YdbForecastListDao;
import com.dfec.water.entity.YdbForecastListEntity;
import com.dfec.water.service.YdbForecastListService;
import com.dfec.water.service.YdbForecastService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author df
 * @title: YdbForecastServiceImpl
 * @description: 预测信息Service业务层处理
 * @date Thu Jan 23 10:20:03 CST 2025
 */
@Service
@RequiredArgsConstructor
public class YdbForecastListServiceImpl extends ServiceImpl<YdbForecastListDao, YdbForecastListEntity> implements YdbForecastListService {

    private final YdbForecastListDao ydbForecastDao;

    private final UidService uidService;

    /**
     * 分页查询
     *
     * @param pageParam 入参
     * @return PageUtils
     * @author df
     * @date Thu Jan 23 10:20:03 CST 2025
     */
    @Override
    public PageUtils queryPage(PageParam<YdbForecastListEntity> pageParam) {
        return ydbForecastDao.selectPage(pageParam);
    }

    /**
     * 不带分页查询
     *
     * @param ydbForecastEntity 入参
     * @return List<YdbForecastListEntity>
     * @author df
     * @date Thu Jan 23 10:20:03 CST 2025
     */
    @Override
    public List<YdbForecastListEntity> listAll(YdbForecastListEntity ydbForecastEntity) {
        return ydbForecastDao.selectAll(ydbForecastEntity);
    }


    @Override
    public boolean save(YdbForecastListEntity entity) {
        if(entity.getForecastId() == null){
            throw new ServiceException("父id不能为空");
        }
        entity.setId(uidService.next());
        return super.save(entity);
    }
}